Skip to content

(WIP) feat(registry): add support for rdap/whois resolving#163

Open
ezrizhu wants to merge 2 commits intonatesales:mainfrom
ezrizhu:feat/rdap-whois
Open

(WIP) feat(registry): add support for rdap/whois resolving#163
ezrizhu wants to merge 2 commits intonatesales:mainfrom
ezrizhu:feat/rdap-whois

Conversation

@ezrizhu
Copy link
Copy Markdown

@ezrizhu ezrizhu commented Apr 27, 2026

This PR adds cli option -g/--registry to resolve internet numbers and domain names.
By default it will use RDAP, and fail back to WHOIS in case the nic does not support it (e.g., nic.gg)

  • auto guesses RIR based off of suffix, e.g., EZRI-RIPE, matches whois(1) behavior

  • allow user to specify rir to use via --rir flag

  • allow user to force rdap or whois via --registry-{whois,rdap}

  • allow user to specify whois/rdap server

  • pretty output

  • nix shell


Summary by cubic

Add registry lookups to resolve domains, IPs, ASNs, and NIC handles via RDAP with a WHOIS fallback using -g/--registry. Supports server/RIR overrides and pretty whois-style output.

  • New Features

    • New flags: -g/--registry, --registry-rdap, --registry-whois, --rdap-server, --whois-server, --rir.
    • Auto-detect RIR from NIC handles (e.g., EZRI-RIPE), with manual override via --rir.
    • RDAP first by default; falls back to WHOIS. Target types are auto-classified.
    • Pretty formatter for RDAP outputs; also supports json and raw.
    • WHOIS follows referrals (refer/ReferralServer) with a safe hop limit and can output hop chain in json.
  • Dependencies

    • Add github.com/openrdap/rdap@v0.9.1 and supporting indirect deps.
    • Add shell.nix for a Go dev environment.

Written for commit 04eab65. Summary will update on new commits. Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="registry/registry.go">

<violation number="1" location="registry/registry.go:141">
P2: RIR routing keys are duplicated across RDAP and WHOIS switch tables, creating drift risk and inconsistent fallback behavior over time.</violation>
</file>

<file name="registry/rdap_pretty.go">

<violation number="1" location="registry/rdap_pretty.go:220">
P2: Parent entity `Public ID` lines are appended after recursive child rendering, so they can end up in a descendant’s section instead of the parent entity block.</violation>
</file>

<file name="registry/whois.go">

<violation number="1" location="registry/whois.go:135">
P2: WHOIS referral parsing is too narrow and misses `Whois Server:` style keys, which can prematurely stop referral-chain resolution.</violation>
</file>

<file name="registry/rdap.go">

<violation number="1" location="registry/rdap.go:67">
P2: RDAP formatter ignores `yaml` and returns pretty/JSON output despite CLI advertising YAML support.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread registry/registry.go
@@ -0,0 +1,171 @@
package registry
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: RIR routing keys are duplicated across RDAP and WHOIS switch tables, creating drift risk and inconsistent fallback behavior over time.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/registry.go, line 141:

<comment>RIR routing keys are duplicated across RDAP and WHOIS switch tables, creating drift risk and inconsistent fallback behavior over time.</comment>

<file context>
@@ -0,0 +1,171 @@
+	return ""
+}
+
+func rirRDAPBase(rir string) string {
+	switch strings.ToLower(rir) {
+	case "arin":
</file context>
Fix with Cubic

Comment thread registry/rdap_pretty.go
b.add("Registration", eventDate(e.Events, "registration"))
b.add("Last Changed", eventDate(e.Events, "last changed"))

for _, child := range e.Entities {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Parent entity Public ID lines are appended after recursive child rendering, so they can end up in a descendant’s section instead of the parent entity block.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/rdap_pretty.go, line 220:

<comment>Parent entity `Public ID` lines are appended after recursive child rendering, so they can end up in a descendant’s section instead of the parent entity block.</comment>

<file context>
@@ -0,0 +1,250 @@
+	b.add("Registration", eventDate(e.Events, "registration"))
+	b.add("Last Changed", eventDate(e.Events, "last changed"))
+
+	for _, child := range e.Entities {
+		appendEntity(b, &child)
+	}
</file context>
Fix with Cubic

Comment thread registry/whois.go
continue
}
switch key {
case "refer", "whois":
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: WHOIS referral parsing is too narrow and misses Whois Server: style keys, which can prematurely stop referral-chain resolution.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/whois.go, line 135:

<comment>WHOIS referral parsing is too narrow and misses `Whois Server:` style keys, which can prematurely stop referral-chain resolution.</comment>

<file context>
@@ -0,0 +1,159 @@
+			continue
+		}
+		switch key {
+		case "refer", "whois":
+			return value
+		case "referralserver":
</file context>
Fix with Cubic

Comment thread registry/rdap.go

func formatRDAP(resp *rdap.Response, format string) (string, error) {
switch strings.ToLower(format) {
case "json", "raw":
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: RDAP formatter ignores yaml and returns pretty/JSON output despite CLI advertising YAML support.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/rdap.go, line 67:

<comment>RDAP formatter ignores `yaml` and returns pretty/JSON output despite CLI advertising YAML support.</comment>

<file context>
@@ -0,0 +1,84 @@
+
+func formatRDAP(resp *rdap.Response, format string) (string, error) {
+	switch strings.ToLower(format) {
+	case "json", "raw":
+		b, err := json.MarshalIndent(resp.Object, "", "  ")
+		if err != nil {
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant